home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / ifp1s158.zip / PAGE_16.PAS < prev    next >
Pascal/Delphi Source File  |  1993-06-26  |  7KB  |  242 lines

  1. unit page_16;
  2.  
  3. interface
  4.  
  5. uses crt, ifpglobl, ifpcomon, ifpextrn;
  6.  
  7. procedure page16;
  8.  
  9. implementation
  10.  
  11. procedure page16;
  12.   var
  13.     bootrec : array[0..secsiz - 1] of byte;
  14.     i : 1..26;
  15.     j : word;
  16.     l : longint;
  17.     xbool : boolean;
  18.     xbyte : byte;
  19.     xchar : char;
  20.     xword1 : word;
  21.     xword2 : word;
  22.     xword3 : word;
  23.     xword4 : word;
  24.     xword5 : word;
  25.     bpbsize: word;
  26.     ch2: char2;
  27.     direc: directions;
  28.  
  29.   begin
  30.   Window(1, 3, twidth div 2, tlength - 2);
  31.   Caption1('Boot record of ');
  32.   drvname(currdrv);
  33.   Writeln;
  34.   xword1:=diskread(currdrv, 0, 1, bootrec);
  35.   if xword1 = $0000 then
  36.     begin
  37.     media(bootrec[$15], bootrec[$0D]);
  38.     Caption3('Sectors/cluster');
  39.     Writeln(bootrec[$0D]);
  40.     Caption3('Bytes/sector');
  41.     Writeln(cbw(bootrec[$0B], bootrec[$0C]));
  42.     Caption3('Reserved sectors');
  43.     Writeln(cbw(bootrec[$0E], bootrec[$0F]));
  44.     Caption3('FAT''s');
  45.     Writeln(bootrec[$10]);
  46.     Caption3('Sectors/FAT');
  47.     Writeln(cbw(bootrec[$16], bootrec[$17]));
  48.     Caption3('Root directory entries');
  49.     Writeln(cbw(bootrec[$11], bootrec[$12]));
  50.     Writeln;
  51.     Caption3('Heads');
  52.     Writeln(cbw(bootrec[$1A], bootrec[$1B]));
  53.     Caption3('Total sectors');
  54.     xword1:=bootrec[$13] + word(bootrec[$14] shl 8);
  55.     if xword1 = 0 then
  56.       begin
  57.       l:=bootrec[$20] + (bootrec[$21] * $100) +
  58.         (bootrec[$22] * $10000) + (bootrec[$23] * $1000000);
  59.       Writeln(l)
  60.       end
  61.     else
  62.       Writeln(cbw(bootrec[$13], bootrec[$14]));
  63.     Caption3('Sectors/track');
  64.     Writeln(cbw(bootrec[$18], bootrec[$19]));
  65.     Caption3('Hidden sectors');
  66.     if xword1 = 0 then
  67.       begin
  68.       l:=bootrec[$1C] + (bootrec[$1D] * $100) +
  69.         (bootrec[$1E] * $10000) + (bootrec[$1F] * $1000000);
  70.       Writeln(l)
  71.       end
  72.     else
  73.       Writeln(cbw(bootrec[$1C], bootrec[$1D]));
  74.     Caption3('OEM name and version');
  75.     for i:=$03 to $0A do
  76.       Write(showchar(Chr(bootrec[i])));
  77.     Writeln;
  78.     Caption3('Extended boot record');
  79.     if (osmajor >= 4) and (bootrec[$26] = $29) then
  80.       begin
  81.       Writeln('yes');
  82.       Caption3('Physical drive number');
  83.       Writeln(bootrec[$24]);
  84.       Caption3('Volume label');
  85.       for j:=$2B to $35 do
  86.         Write(showchar(Chr(bootrec[j])));
  87.       Writeln;
  88.       Caption3('Serial Number');
  89.       Writeln(hex(cbw(bootrec[$29], bootrec[$2A]), 4), '-',
  90.         hex(cbw(bootrec[$27], bootrec[$28]), 4));
  91.       Caption3('FAT type');
  92.       for j:=$36 to $3D do
  93.         Write(showchar(Chr(bootrec[j])))
  94.       end
  95.     else
  96.       Writeln('no')
  97.     end
  98.   else
  99.     begin
  100.     Writeln('  Can''t read boot record');
  101.     Write('  ');
  102.     xbyte:=hi(xword1);
  103.     case xbyte of
  104.       $80 : Writeln('Attachment failed to respond');
  105.       $40 : Writeln('Seek operation failed');
  106.       $20 : Writeln('Controller failed');
  107.       $10 : Writeln('Data error (bad CRC)');
  108.       $08 : Writeln('DMA failure');
  109.       $04 : Writeln('Sector not found');
  110.       $03 : Writeln('Write-protect fault');
  111.       $02 : Writeln('Bad address mark');
  112.       $01 : Writeln('Bad command');
  113.       $00 : Writeln
  114.       else
  115.         unknown('error', xbyte, 2)
  116.     end;
  117.     Write('  ');
  118.     xbyte:=lo(xword1);
  119.     case xbyte of
  120.       $00 : Writeln('Write-protect error');
  121.       $01 : Writeln('Unknown unit');
  122.       $02 : Writeln('Drive not ready');
  123.       $03 : Writeln('Unknown command');
  124.       $04 : Writeln('Data error (bad CRC)');
  125.       $05 : Writeln('Bad request structure length');
  126.       $06 : Writeln('Seek error');
  127.       $07 : Writeln('Unknown media type');
  128.       $08 : Writeln('Sector not found');
  129.       $09 : Writeln('Printer out of paper');
  130.       $0A : Writeln('Write fault');
  131.       $0B : Writeln('Read fault');
  132.       $0C : Writeln('General failure')
  133.       else
  134.         unknown('error', xbyte, 2)
  135.     end;
  136.     if osmajor >= 10 then
  137.       begin
  138.       Writeln;
  139.       xbyte:=TextAttr;
  140.       TextColor(LightRed);
  141.       Writeln('**NOTICE**');
  142.       TextAttr:=xbyte;
  143.       Writeln('Information for SUBST''d drives');
  144.       Writeln('is not available under OS/2.');
  145.       Writeln('If you recieved an Unknown unit');
  146.       Writeln('error, change to a real drive');
  147.       Writeln('and try INFOPLUS again.');
  148.       end;
  149.     end;
  150.   Window(1 + twidth div 2, 3, twidth, tlength - 2);
  151.   i:=1;
  152.   xbool:=false;
  153.   xword1:=MemW[devseg : devofs + $0018];
  154.   xword2:=MemW[devseg : devofs + $0016];
  155.   if not ((xword1 = $FFFF) and (xword2 = $FFFF)) then
  156.     begin
  157.     if (osmajor >= 4) and (osmajor < 10) then
  158.       begin
  159.       xbyte:=1;
  160.       bpbsize:=$58
  161.       end
  162.     else
  163.       begin
  164.       xbyte:=0;
  165.       bpbsize:=$51
  166.       end;
  167.     repeat
  168.       Caption1('DOS disk parameter block for ');
  169.       xword2:=MemW[devseg : devofs + $0016] + ((i - 1) * bpbsize);
  170.       drvname(i - 1);
  171.       Writeln;
  172.       xword3:=MemW[xword1 : xword2 + $0047];
  173.       xword4:=MemW[xword1 : xword2 + $0045];
  174.       media(Mem[xword3 : xword4 + $0016 + xbyte],
  175.             Mem[xword3 : xword4 + $0004] + 1);
  176.       Caption3('Sectors/cluster');
  177.       Writeln(Mem[xword3 : xword4 + $0004] + 1);
  178.       Caption3('Bytes/sector');
  179.       Writeln(MemW[xword3 : xword4 + $0002]);
  180.       Caption3('Reserved sectors');
  181.       Writeln(MemW[xword3 : xword4 + $0006]);
  182.       Caption3('FAT''s');
  183.       Writeln(Mem[xword3 : xword4 + $0008]);
  184.       Caption3('Sectors/FAT');
  185.       if (osmajor >= 4) and (osmajor <10) then
  186.         Writeln(Mem[xword3:xword4 + $000F] +
  187.             (Mem[xword3:xword4 + $0010] * 256))
  188.       else
  189.         Writeln(Mem[xword3 : xword4 + $000F]);
  190.       Caption3('Root directory entries');
  191.       Writeln(MemW[xword3 : xword4 + $0009]);
  192.       Writeln;
  193.       Caption3('DPB valid');
  194.       yesorno(Mem[xword3 : xword4 + $0017 + xbyte] < $FF);
  195.       Caption3('Current directory');
  196.       j:=xword2;
  197.       xchar:=Chr(Mem[xword1 : j]);
  198.       while xchar > #0 do begin
  199.         Write(xchar);
  200.         inc(j);
  201.         xchar:=Chr(Mem[xword1 : j])
  202.       end;
  203.       Writeln;
  204.       Caption3('Device header');
  205.       segofs(MemW[xword3 : xword4 + $0014 + xbyte],
  206.         MemW[xword3 : xword4 + $0012 + xbyte]);
  207.       Writeln;
  208.       Caption3('Unit within driver');
  209.       Writeln(Mem[xword3 : xword4 + $0001]);
  210.       Caption3('Clusters');
  211.       Writeln(MemW[xword3 : xword4 + $000D] - 1);
  212.       Caption3('Cluster to sector shift');
  213.       Writeln(Mem[xword3 : xword4 + $0005]);
  214.       Caption3('Root directory sector');
  215.       Writeln(MemW[xword3 : xword4 + $0010 + xbyte]);
  216.       Caption3('First data sector');
  217.       Writeln(MemW[xword3 : xword4 + $000B]);
  218.       Caption3('Next DPB');
  219.       xword5:=MemW[xword3 : xword4 + $0018 + xbyte];
  220.       segofs(MemW[xword3 : xword4 + $001A + xbyte], xword5);
  221.       Writeln;
  222.       if i = 1 then
  223.         direc:=down
  224.       else
  225.         if (i = lastdrv) or (xword5 = $FFFF) then
  226.           direc:=up
  227.         else
  228.           direc:=updown;
  229.       Write('  ');
  230.       pause4(direc, ch2);
  231.       if endit then
  232.         Exit;
  233.       if (ch2 = #0#72) and (i > 1) then
  234.         Dec(i)
  235.       else
  236.         if (ch2 = #0#80) and (i < lastdrv) and (xword5 < $FFFF) then
  237.           Inc(i);
  238.       ClrScr;
  239.     until xbool
  240.     end;
  241.   end;
  242. end.